 

function documentInsideCtrl($scope, $http) {
  'ngInject';
  // 档案盒数据
  this.documentList = [];

  this.innerList = {};
  let id = $state.params.id;

  // 判断条件跳转到
  this.toCheckItem = (innerItem, toDetailFlag) => {
    // 去打分页面
    if (!toDetailFlag) {
      $state.go('documentItemMgt', {
        id: innerItem.checkClassifyId,
        type: 'check',
        imgUrl: innerItem.src,
        name: innerItem.checkClassifyName,
        taskId: id,
      });
    } else { // 去详情页面
      $state.go('documentInsideDetail', {
        taskId: id,
        innerItemId: innerItem.checkClassifyId,
        imgUrl: innerItem.src,
      });
    }
   
  }

  // 获取专项检查信息
  this.specialInspection = () => {
    $http.get(`${SERVER_CONTEXT}/api/securityActivities/specialCheck/querySpecialCheckById/${id}`)
      .then((resp) =>{
        
        this.innerList = resp.data.securityCheckClassifyMap.inner;
        let categoryListCache = this.innerList
          ,checkedCategoryList = [],uncheckedCategoryList = [];

        // 遍历ajax返回数据,获得14个考核项
        for(let i=0; i<categoryListCache.length; i++){
          let categoryItem = categoryListCache[i];
          let checkCategoryName = categoryItem.checkClassifyName;
          switch(checkCategoryName) {
            case "责任落实":
                  categoryItem.src = 'book-1.png';
                  break;
            case "管理制度":
                  categoryItem.src = 'book-2.png';
                  break;
            case "工作策划":
                  categoryItem.src = 'book-3.png';
                  break;
            case "人员管理":
                  categoryItem.src = 'book-4.png';
                  break;
            case "安全活动":
                  categoryItem.src = 'book-5.png';
                  break;
            case "船机设备":
                  categoryItem.src = 'book-6.png';
                  break;
            case "临时用电":
                  categoryItem.src = 'book-7.png';
                  break;
            case "风险预控":
                  categoryItem.src = 'book-8.png';
                  break;
            case "专项方案":
                  categoryItem.src = 'book-9.png';
                  break;
            case "危化消防":
                  categoryItem.src = 'book-10.png';
                  break;
            case "应急管理":
                  categoryItem.src = 'book-11.png';
                  break;
            case "专项经费":
                  categoryItem.src = 'book-12.png';
                  break;
            case "检查评价":
                  categoryItem.src = 'book-13.png';
                  break;
            case "事故管理":
                  categoryItem.src = 'book-14.png';
                  break;
            default:
                  break;
          }
          if (categoryItem.check) {
            checkedCategoryList.push(categoryItem);
          } else {
            uncheckedCategoryList.push(categoryItem);
          }
        }

        // 未考核完考核项数据加入$scope
        this.documentList = uncheckedCategoryList;
        // 将原始数据变化为行展示内容
        this.uncheckedDocumentList4show = this.getDocumentList4show();

        // 未考核完考核项数据加入$scope
        this.documentList = checkedCategoryList;
        // 将原始数据变化为行展示内容
        this.checkedDocumentList4show = this.getDocumentList4show();
    });
  };
  this.specialInspection();

  this.shouldTableShow = false;

  this.loadImage = function(image) {
      return require('../../../assets/images/' + image.src);
  };
  // 处理档案盒数据用于展示
  this.getDocumentList4show= () => {
    let step = 0;
    let index = 0;
    let result = [];
    this.documentList.forEach((item) => {
      if (step%5 == 0) {
        result.push([]);
      }
      index = result.length;
      step++;
      result[index-1].push(item);
    });
    return result;
  };

  this.documentList4show = this.getDocumentList4show();

}

export default documentInsideCtrl;